using HHHFramework;
using HotFix;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestPool : MonoBehaviour
{
    public List<HeroUIView> heroUIViewArrray = new List<HeroUIView>();
    // Start is called before the first frame update
    void Start()
    {
        CreateObjectUtil.CreateChild<PoolManager>("PoolManager", transform);
        PoolManager.Instance.Ini();
        HeroUIView heroUIView = PoolManager.Instance.AllocatePrefab<HeroUIView>("resources://HeroUIView", count:2);
        heroUIView.transform.parent = this.transform;
        heroUIView.gameObject.SetActive(true);
        heroUIViewArrray.Add(heroUIView);
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1)) {
            HeroUIView heroUIView = PoolManager.Instance.AllocatePrefab<HeroUIView>("resources://HeroUIView");
            heroUIView.transform.parent = this.transform;
            heroUIView.gameObject.SetActive(true);
            heroUIViewArrray.Add(heroUIView);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            if (heroUIViewArrray.Count!=0) {
                var heroUIView = heroUIViewArrray[heroUIViewArrray.Count - 1];
                heroUIView.gameObject.SetActive(false);
                PoolManager.Instance.Retrieve<HeroUIView>(heroUIView, "resources://HeroUIView");
                heroUIViewArrray.Remove(heroUIView);
            }
         
            
        }
    }
}
